<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--Converted with LaTeX2HTML 96.1 (Feb 5, 1996) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds -->


<title>Ackermann Functions</title>
<meta name="description" content="Ackermann Functions">
<meta name="keywords" content="htmlatex">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<link rel="STYLESHEET" href="acm-00371_archivos/htmlatex.css">
</head><body bgcolor="#ffffff" lang="EN">
 <h1><br clear="all"><center><table bgcolor="#0060f0"><tbody><tr><td><b><font color="#c0ffff" size="5">&nbsp;<a name="SECTION0001000000000000000000">Ackermann Functions</a></font>&nbsp;</b></td></tr></tbody></table></center></h1>
<p>
     An Ackermann function has the characteristic that the length of the
sequence of numbers generated by the function cannot be computed directly
from the input value.  One particular integer Ackermann function is the
following:
</p><p> <img alt="displaymath32" src="acm-00371_archivos/371img1.gif" align="bottom" height="40" width="379"> </p><p>
</p><p>
This Ackermann has the characteristic that it eventually converges on 1.  A
few examples follow in which the starting value is shown in square brackets
followed by the sequence of values that are generated, followed by the length
of the sequence in curly braces:
</p><p>
</p><pre>     [10] 5 16 8 4 2 1 {6}
     [13] 40 20 10 5 16 8 4 2 1 {9}
     [14] 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 {17}
     [19] 58 29 88 44 22 ... 2 1 {20}
     [32] 16 8 4 2 1 {5}
     [1] 4 2 1 {3}</pre>
<p>
</p><h2><font color="#0070e8"><a name="SECTION0001001000000000000000">Input and Output</a></font></h2>
<p>
Your program is to read in a series of pairs of values that represent the
first and last numbers in a closed sequence.  For each closed sequence pair
determine which value generates the longest series of values before it
converges to 1.  The largest value in the sequence will not be larger than
can be accomodated in a 32-bit Pascal LongInt or C long.  The last pair of
values will be 0, 0.  The output from your program should be as follows:
</p><p>
</p><p>
</p><p>
<tt>Between</tt> <i>L</i> <tt>and</tt> <i>H</i>, <i>V</i> <tt>generates the longest sequence of</tt>
 <i>S</i> <tt>values.</tt>
</p><p>
</p><p>
</p><p>
Where:
</p><p>
<i>L</i> = the lower boundary value in the sequence
</p><p>
<i>H</i> = the upper boundary value in the sequence
</p><p>
<i>V</i> = the first value that generates the longest sequence, 
                   (if two or more values generate the longest sequence 
                    then only show the lower value)
<i>S</i> = the length of the generated sequence.
</p><p>
</p><p>
In the event that two numbers in the interval should both produce equally
long sequences, report the first.
</p><p>
</p><h2><font color="#0070e8"><a name="SECTION0001002000000000000000">Sample Input</a></font></h2>
<p>
</p><pre>  1 20
 35 55
  0 0</pre>
<p>
</p><h2><font color="#0070e8"><a name="SECTION0001003000000000000000">Sample Output</a></font></h2>
<p>
</p><pre>Between 1 and 20, 18 generates the longest sequence of 20 values.
Between 35 and 55, 54 generates the longest sequence of 112 values.</pre>
<p>
</p></body></html>